@echo off
title Weiyun One-Click Installer
chcp 65001 > nul

echo.
echo ================================================================
echo                   Weiyun One-Click Installer
echo ================================================================
echo.
echo Starting PowerShell to execute online installation script...
echo.

rem Check administrator privileges
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo [Notice] Administrator privileges required, requesting elevation...
    powershell -Command "Start-Process '%~f0' -Verb RunAs"
    exit /b
)

rem Execute online script with proper output handling
powershell -ExecutionPolicy Bypass -Command "$ProgressPreference = 'Continue'; try { Write-Host 'Downloading and executing online script...' -ForegroundColor Green; $script = irm https://gitee.com/xavierlab/weiyun_downloader/raw/main/weiyun_installer_online.ps1; Write-Host 'Script downloaded, executing...' -ForegroundColor Green; iex $script } catch { Write-Host '[Error] Online script execution failed, please check network connection' -ForegroundColor Red; Write-Host 'Error details:' $_.Exception.Message -ForegroundColor Red; Read-Host 'Press Enter to exit' }"

echo.
echo Installation completed!
pause